package com.wenjiang.service.impl;

import com.wenjiang.http.LanTuWxPayHttpClient;
import com.wenjiang.model.request.LantuWxPayNativeOrderWxRequest;
import com.wenjiang.model.request.LantuWxPayQueryOrderWxRequest;
import com.wenjiang.model.request.LantuWxPayRefundOrderWxRequest;
import com.wenjiang.model.response.LantuWxPayNativeOrderResult;
import com.wenjiang.model.response.LantuWxPayQueryOrderResult;
import com.wenjiang.model.response.LantuWxPayRefundOrderResult;
import com.wenjiang.service.LanTuWXNativePayService;

/**
 * <p>
 *  蓝兔PC扫码支付实现
 * </p>
 *
 * @author lwj
 * @since 2024/11/29.
 */
public class LanTuWxNativeServiceImpl implements LanTuWXNativePayService {


    private LanTuWxPayHttpClient lanTuWxPayHttpClient;



    public LanTuWxNativeServiceImpl(LanTuWxPayHttpClient lanTuWxPayHttpClient) {
        this.lanTuWxPayHttpClient = lanTuWxPayHttpClient;
    }

    /**
     * 创建订单api
     */
    private static  final String CREATE_ORDER_API = "/api/wxpay/native";


    /**
     * 查询订单api
     */
    private static  final  String  QUERY_ORDER_API = "/api/wxpay/get_pay_order";

    /**
     * 发起退款api
     */
    private static final String  REFUND_ORDER_API = "/api/wxpay/refund_order";




    /**
     * 发起微信支付
     * @param lantuWxPayNativeOrderWxRequest
     * @return
     */
    @Override
    public LantuWxPayNativeOrderResult createOrder(LantuWxPayNativeOrderWxRequest lantuWxPayNativeOrderWxRequest) {
        return lanTuWxPayHttpClient.sendPost(CREATE_ORDER_API,lantuWxPayNativeOrderWxRequest,LantuWxPayNativeOrderResult.class);
    }

    /**
     * 查询微信支付订单
     * @param lantuWxPayQueryOrderWxRequest
     * @return
     */
    @Override
    public LantuWxPayQueryOrderResult queryOrder(LantuWxPayQueryOrderWxRequest lantuWxPayQueryOrderWxRequest) {
        return lanTuWxPayHttpClient.sendPost(QUERY_ORDER_API,lantuWxPayQueryOrderWxRequest,LantuWxPayQueryOrderResult.class);
    }



    /**
     * 发起微信退款订单
     * @param lantuWxPayRefundOrderWxRequest
     * @return
     */
    @Override
    public LantuWxPayRefundOrderResult refundOrder(LantuWxPayRefundOrderWxRequest lantuWxPayRefundOrderWxRequest) {
        return lanTuWxPayHttpClient.sendPost(REFUND_ORDER_API,lantuWxPayRefundOrderWxRequest,LantuWxPayRefundOrderResult.class);
    }
}
